const PrefixBrowser = ['-webkit-', '-moz-', '-ms-', '-o-', ''];

const ReactPrefixBrowser = ['Ms', 'Moz', 'Webkit', 'O', ''];

export const isPc = () => {
  let userAgentInfo = navigator.userAgent;
  let Agents = [
    'Android',
    'iPhone',
    'SymbianOS',
    'Windows Phone',
    'iPad',
    'iPod',
  ];
  let flag = true;
  for (let v = 0; v < Agents.length; v++) {
    if (userAgentInfo.indexOf(Agents[v]) > 0) {
      flag = false;
      break;
    }
  }
  return flag;
};

export const setCssStyle = (
  obj: any,
  name: string | number,
  val: string | number,
  reactObj = false,
) => {
  (reactObj ? ReactPrefixBrowser : PrefixBrowser).forEach(item => {
    obj[item + name] = val;
  });
};
